package com.yy.micro.magic;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@ComponentScan
public class MagicConfiguration {

    @Configuration
    @EnableOpenApi
    public class Swagger2Config{
        @Bean
        public Docket magicDocket(ApiInfoBuilder magicApiInfo){
            return new Docket(DocumentationType.OAS_30)
                    .apiInfo(magicApiInfo.build())
                    .groupName("Magic Cube")
                    .select()
                    .paths(PathSelectors.any())
                    .build();
        }

        @ConfigurationProperties(prefix = "spring.swagger2")
        @Bean
        public ApiInfoBuilder magicApiInfo(){
            return new ApiInfoBuilder();
        }
    }
}
